<?php

//
// +------------------------------------------------------------------------+
// | PHP Version 5.4                                                        |
// +------------------------------------------------------------------------+
// | Copyright (c) All rights reserved.                                     |
// +------------------------------------------------------------------------+
// | 世纪车来车往(北京）网络科技有限公司 版权所有！                               |
// | TEL:010-63732365  HOTLINE:400-6688-365  EMAIL:clcw@clcw.com.cn         |
// | $Revision: 1.0 $                                                       |
// +------------------------------------------------------------------------+
// | Author: xiangminghu@clcw.com.cn                                        |
// +------------------------------------------------------------------------+
//

namespace AuctionBack\Controller;

use AuctionCore\Other\DealerFeedback;
/**
 * Description of FeedBackController
 *
 * @author xmh
 */
class DealerFeedBackController extends BaseController {

    public function __construct() {
        parent::__construct();
        $this->emp_id = $this->user_info['emp_id'];
        //模板赋值
        $this->assign("emp_id", $this->emp_id);
    }

    /**
     * 获取信息列表
     */
    public function index() {
        $this->display();
    }

    public function dealer_feedback_list() {
        $page = I("get.p", 1);
        $start_time = I("get.start_time");
        $end_time = I("get.end_time");
        $feedback_type = I("get.feedback_type");
        $keyword = I("get.keyword");
        $status = I("get.status");
        $size = 3;
        $params = array();
        $emp_id = $this->emp_id;
        $params['start_time'] = $start_time;
        $params['end_time'] = $end_time;
        $params['feedback_type'] = $feedback_type;
        $params['keyword'] = $keyword; 
        $params['status'] = $status;   
        //获取list
        $aol = new \AuctionCore\Other\DealerFeedback();
        $result = $aol->dealer_feedback_list($page, $size, $params);
        $Page = new \AuctionCore\Common\AjaxPage($result['total'], $size, "get_dealer_feedback_page");
        $Page->setConfig('theme', " %totalRow% %header% %nowPage%/%totalPage% 页 %first% %upPage% %prePage% %linkPage% %downPage% %nextPage% %end% %jumpform%");
        $show = $Page->show();  // 分页显示输出
        //模板赋值
        $this->assign('page', $show); // 赋值分页输出
        $this->assign('list', $result['list']);
        $this->display();
    }
    /**
     * 回复处理
     */
    public function reply_post(){
        $df_id = I("post.df_id");
        $mark = I("post.mark");
        $feedback = M('DealerFeedback')->field('mark')->where(array('df_id'=>$df_id))->find();
        if ($mark =='') {
            $this->helpJsonResult(411, "回复内容不能为空！");
        }
        if($feedback['status'] == 1){
            $this->helpJsonResult(412, "该问题已经解决！");
        }
        $data = array();
        $data['mark'] = $mark;
        $data['status'] = 1;
        $data['emp_id'] = $this->emp_id;
        $data['replytime'] = date("Y-m-d H:i:s");
        $res = M('DealerFeedback')->where(array('df_id'=>$df_id))->save($data);
        if($res){
            $data['username'] = $this->user_info['username'];
            $this->helpJsonResult(200, "回复成功！",$data);
        }
    }

}
